#!/usr/bin/env python
#coding=utf-8

import json
import logging
from pprint import pprint
from huaweicloudsdkcore.auth.credentials import GlobalCredentials
from huaweicloudsdkcore.exceptions import exceptions

from core.logger import logger
from setting import config


class HuaweiYunClient(object):
    def __init__(self):
        pass

    # v2 版本使用方式
    def get_all_credentials(self):
        huaweiyun_credentials = [
            {
                "name": config.TIANMIANTECH_ACCOUNT,
                "credentials": GlobalCredentials(config.TIANMIANTECH_ACCESS_KEY, config.TIANMIANTECH_ACCESS_SECRET)
            },
            {
                "name": config.WELABCLOUD_ACCOUNT,
                "credentials": GlobalCredentials(config.WELABCLOUD_ACCESS_KEY, config.WELABCLOUD_ACCESS_SECRET)
            }
        ]

        return huaweiyun_credentials


    def get_one_credentials(self, account_name):
        huaweiyun_credentials = self.get_all_credentials()
        for huaweiyun_credential in huaweiyun_credentials:
            if huaweiyun_credential["name"] == account_name:
                return huaweiyun_credential["credentials"]

        return None




def main():
    huawei_yun_client = HuaweiYunClient()


if __name__ == "__main__":
    main()